/* $RCSFile: ProviderConfiguration.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.UrlBuilderProvider/ProviderConfiguration.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:31  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;

using AddonNice.Web;

namespace AddonNice.Configuration.Provider
{
	/// <summary>
	/// Class to read the UrlService section in Web.config
	/// </summary>
    public class UrlServiceSection : ConfigurationSection
    {
        [ConfigurationProperty("providers")]
        public ProviderSettingsCollection Providers
        {
            get 
            { 
                if ( ProviderTraceSwitch.Sw.TraceVerbose )
                    Trace.WriteLine( "[V]UrlServiceSection Providers GET BEG.",ProviderTraceSwitch.Sw.Info);
                ProviderSettingsCollection col  =    (ProviderSettingsCollection)base["providers"]; 
                if ( ProviderTraceSwitch.Sw.TraceVerbose )
                    Trace.WriteLine(string.Format(CultureInfo.InvariantCulture,"[V]UrlServiceSection Providers GET END Count: {0}.",col.Count),ProviderTraceSwitch.Sw.Info);
                return col;
            }
        }

        [StringValidator(MinLength = 1)]
        [ConfigurationProperty("defaultProvider", DefaultValue = "ADNUrlBuilder")]
        public string DefaultProvider
        {
            get 
            { 
                string str      =   (string)base["defaultProvider"];
                if ( ProviderTraceSwitch.Sw.TraceVerbose )
                    Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]UrlServiceSection DefaultProvider GET BEG: '{0}'.",str),ProviderTraceSwitch.Sw.Info);
                return str; 
            }
            set 
            { 
                if ( ProviderTraceSwitch.Sw.TraceVerbose )
                    Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]UrlServiceSection DefaultProvider SET BEG value: '{0}'.",value),ProviderTraceSwitch.Sw.Info);
                base["defaultProvider"] = value; 
            }
        }
    }
}
